Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #164

Merged
merged 164 commits into from
Mar 11, 2024
Merged

V2 #164

merged 164 commits into from
Mar 11, 2024

Conversation

kke
Copy link
Contributor

@kke kke commented Jan 30, 2024

Pretty much everything has been changed and touched.

Increased modularity and thus improved extendability, flexibility, testability and component reusability.

Context is finding its way in. There is for example h.ExecContext(ctx, ...) and h.Connect(ctx).

Short summary of changes to usage:

Exec.Sudo() is gone.

// before:
h.Exec("command", exec.Sudo())
h.SudoFsys().OpenFile(...)
// after:
h.Sudo().Exec("command")
h.Sudo().FS().OpenFile(...)

There's no more "Execf".

// before
h.Execf("command %s", shellescape.Quote(path))
// after
h.Exec(sh.Command("command", path)) // path is automatically quoted like in os/exec.

Configurers are gone. You may still need to implement them for your own usecases, but they're no longer in rig. Instead, the functionality has been spread out to different components and more stdlib os resembling functionality bundled with the fs.FS implementation in rig/remotefs.

// before
h.Configurer.WriteFile("foo.txt", "content")
// after
h.FS().WriteFile("foo", []byte("content"), 0o600)

// before
h.Configurer.InstallPackages(h, "curl", "iptables")
// after
h.Sudo().PackageManager().Install(context.Background(), "curl", "iptables")

// before
h.Configurer.StartService(h, "foo")
// after
h.Service("foo").Start(context.Background())

A great chunk of replicated logic in each of the protocol client implementations was moved to a centralized cmd.Executor. The protocols now only need to implement a single StartProcess function, all of the output capturing, input relaying and so on is done in the executor.

There are a number of io.Writers and io.Readers now used internally for things that were done with string manipulations before. Many of these are reusable for other stuff.

TODO - this PR does not include much refactoring for the connection setup stuff, which has become quite difficult to maintain due to its complexity, especially the SSH. That will be addressed in a separate PR before a final 2.0.0 is tagged.

@kke kke added enhancement New feature or request go Pull requests that update Go code labels Jan 31, 2024
@kke kke force-pushed the exec-runner-refactor branch 4 times, most recently from 8345ab9 to 0cbf539 Compare February 10, 2024 19:17
@kke kke force-pushed the exec-runner-refactor branch 10 times, most recently from e83675f to 0cbcf82 Compare February 19, 2024 21:05
@kke kke force-pushed the exec-runner-refactor branch 3 times, most recently from d4d105f to 952e6dc Compare February 23, 2024 22:14
@kke kke changed the title [wip] Small refactoring that ended up being not that small rig V2 Mar 8, 2024
@kke kke changed the title rig V2 V2 Mar 8, 2024
kke added 21 commits March 10, 2024 23:44
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
Signed-off-by: Kimmo Lehto <[email protected]>
@kke kke force-pushed the exec-runner-refactor branch 2 times, most recently from 2846eac to 540912d Compare March 10, 2024 22:55
Signed-off-by: Kimmo Lehto <[email protected]>
@kke kke marked this pull request as ready for review March 11, 2024 07:18
@kke kke merged commit fc225b5 into main Mar 11, 2024
10 checks passed
@kke kke deleted the exec-runner-refactor branch March 11, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant